import java.util.Iterator;
import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-04
 * Time: 14:48
 */

//源码分析
public class LinkedListCRUD {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {

        LinkedList linkedList = new LinkedList();
        //添加
        linkedList.add(1);
        linkedList.add(2);
        System.out.println("linkedList=" + linkedList);

        //分析
        //1.LinkedList linkedList = new LinkedList();
        //    public LinkedList() {
        //    }
        //2.

        //删除 默认删除第一个元素
        System.out.println(linkedList.remove());
        System.out.println("linkedList=" + linkedList);

        //修改
        linkedList.set(0,999);
        System.out.println("linkedList=" + linkedList);

        //得到节点对象get
        System.out.println(linkedList.get(0));

        //遍历 LinkedList 实现了List接口
        Iterator iterator = linkedList.iterator();
        while (iterator.hasNext()) {
            Object next =  iterator.next();
            System.out.println(next);

        }


        //增强For  普通遍历
        System.out.println(linkedList.size());

    }
}
